package com.huangbc.servicemap.controller;

import com.alibaba.fastjson.JSONObject;
import com.huangbc.internalcommon.dto.DicDistrict;
import com.huangbc.internalcommon.dto.TrackResult;
import com.huangbc.servicemap.mapper.DicDistrictMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: Derek.huang on 2024/3/28 19:06.
 */
@RestController
public class TestController {
    @GetMapping("/test")
    public String test(){
        return "service map";
    }


    @Autowired
    private DicDistrictMapper mapper;

    @GetMapping("/test-map")
    public String testMap(){
        Map<String,Object> map = new HashMap<>();
        map.put("address_code","110000");
        List<DicDistrict> dicDistricts = mapper.selectByMap(map);
        System.out.println(dicDistricts);

        return "test-map";
    }

    public static void main(String[] args) {
        String json= "{\"errcode\":10000,\"errmsg\":\"OK\",\"data\":\n" +
                "{\"tracks\":[{\"startPoint\":{\"location\":\"104.054488,30.577875\",\"locatetime\":1724030846109},\n" +
                "\"endPoint\":{\"location\":\"104.054488,30.577875\",\"locatetime\":1724030846109},\"trid\":379,\"distance\":0,\"time\":0,\"counts\":1,\n" +
                "\"points\":[{\"location\":\"104.054488,30.577875\",\"locatetime\":1724030846109,\"speed\":255.0,\"direction\":511.0,\"accuracy\":550.0}]}],\n" +
                "\"counts\":1}}";
        JSONObject jsonObject = JSONObject.parseObject(json);
        String tracks = jsonObject.getString("data");
        TrackResult trackResult = JSONObject.parseObject(tracks, TrackResult.class);
        System.out.println(trackResult);

    }
}
